#include "itemeditdialog.h"

#include "contentitem.h"

ItemEditDialog::ItemEditDialog(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::ItemEditDialogClass())
{
	ui->setupUi(this);

	connect(ui->okBtn, &QPushButton::clicked, this, &ItemEditDialog::onOkBtnClicked);
	connect(ui->cancelBtn, &QPushButton::clicked, this, &ItemEditDialog::onCancelBtnClicked);
}

void ItemEditDialog::setContentItem(ContentItem* item)
{
	ui->finishCheckBox->setChecked(item->isFinished());
	ui->lineEdit->setText(item->getText());
}

QSharedPointer<ContentItem> ItemEditDialog::getContentItem()
{
	QSharedPointer<ContentItem> item(new ContentItem);
	item->setText(ui->lineEdit->text());
	item->setFinished(ui->finishCheckBox->isChecked());
	return item;
}

ItemEditDialog::~ItemEditDialog()
{
	delete ui;
}

void ItemEditDialog::onOkBtnClicked()
{
	this->accept();
}

void ItemEditDialog::onCancelBtnClicked()
{
	this->reject();
}

